package Demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 34255
 * Date: 2024-07-06
 * Time: 16:59
 */
public class myArray<T extends Comparable<T>>{
    private Object[] array = new Object[10];

    public void setVal(int pos,T val){
        this.array[pos] = val;
    }

    public T getVal(int pos){
        return (T)this.array[pos];
    }

    public T findMax(T array[]){
        T max = array[0];
        for (int i = 1; i < array.length; i++) {
            if(max.compareTo(array[i]) > 0){
                max = array[i];
            }
        }
        return max;
    }

    public static void main(String[] args) {
        myArray<Integer> myArray = new myArray<Integer>();
        myArray.setVal(0,1);
        myArray.setVal(1,2);
        Integer a = myArray.getVal(0);
        System.out.println(myArray.getVal(1));
    }
    public static void main3(String[] args) {
//        myArray<String> myArray = new myArray<String>();
//        myArray.setVal(0,"hello");
//        myArray.setVal(1,"abc");
//        String str1 = myArray.getVal(0);
//        String str2 = myArray.getVal(1);
//        System.out.println(str1 + str2);
    }
//    public static void main2(String[] args) {
//        myArray<Integer> myArray = new myArray<Integer>();
//        myArray.setVal(0,1);
//        myArray.setVal(1,2);
//        System.out.println(myArray.getVal(0));
//        System.out.println(myArray.getVal(1));
//    }
//    public static void main1(String[] args) {
//        myArray array = new myArray();
//        array.setVal(0,10);
//        array.setVal(1,"hello");
//        System.out.println(array.getVal(0));
////        System.out.println(array.getVal(1));
//        String str = (String)array.getVal(1);
//        System.out.println(str);
//    }
}
